// -*- c++ -*-
/**************************************************************/
/*  This file is licensed from, and is a trade secret of:     */
/*                                                            */
/*    Mercury Computer Systems, Incorporated                  */
/*    199 Riverneck Road                                      */
/*    Chelmsford, Massachusetts 01824-2820                    */
/*    United States of America                                */
/*    Telephone + 1 978 256-1300                              */
/*                                                            */
/*  Refer to your Software License Agreement for provisions   */
/*  on use, duplication, or disclosure.                       */
/*  US. Government users and prime contractors are also       */
/*  governed by the following Data Rights Notice:             */
/*  Use, duplication or disclosure by the US. Government is   */
/*  subject to the provisions set forth in FAR 52.227-14 for  */
/*  restricted rights or other agency data rights provisions  */
/*  on commercial software and documentation, as applicable.  */
/*                                                            */
/*  This file: (a) was developed at private expense, and no   */
/*  part was developed with government funds, (b) is a        */
/*  trade secret of Mercury Computer Systems, Inc. for the    */
/*  purposes of the Freedom of Information Act, (c) is        */
/*  "commercial computer software" subject to limited         */
/*  utilization as provided in the above noted Software       */
/*  License Agreement and (d) is in all respects data         */
/*  belonging exclusively to Mercury Computer Systems, Inc..  */
/*                                                            */
/**************************************************************/

/******************************************************************/
/* Copyright (c) 1999-2003, Mercury Computer Systems, Inc.,       */
/* Chelmsford MA.,and all third party embedded software sources.  */
/* All rights reserved under the Copyright laws of US. and        */
/* international treaties.                                        */
/*                                                                */
/* Patent Pending                                                 */
/******************************************************************/


//$COPYRIGHT_END


#ifndef MAC_RECEIVE_H__
#define MAC_RECEIVE_H__

#include "CF__Resource_impl.h"
#include "CF__Port_impl.h"
#include "macS.h"
#include "mac.h"
#include "mac_port.h"
#include "mc_error.h"

class MAC_EXPORT MacReceive
  : public CF__Resource_impl
{
public: 
  static status
  Create (MacReceive *& ModulatorHandle,
	  const char * identifier);

  // From CF::Resource
  void start ()
    throw (CORBA::SystemException, CF::Resource::StartError);
  void stop ()
    throw (CORBA::SystemException, CF::Resource::StopError);

  // From CF::PortSupplier
  CORBA::Object_ptr getPort (const CORBA::Char * name)
    throw (CORBA::SystemException, CF::PortSupplier::UnknownPort);

  // From POA_SDR_FM3TR::MAC_Signaling::MAC_FlowControl_Local
  void signalHighWatermark ()
    throw (CORBA::SystemException);
  void signalLowWatermark ()
    throw (CORBA::SystemException);
  void signalEmpty ()
    throw (CORBA::SystemException);

  // From POA_SDR_FM3TR::MAC_Signaling::MAC_ErrorControl_ReceiveLocal
  void signalACK ()
    throw (CORBA::SystemException);
  void signalNAK ()
    throw (CORBA::SystemException);

private:
  MacReceive (const char * identifier);
  ~MacReceive ();

  status Init ();

  void SendFeedback ();

  // Provides interface definitions.
  MAC_ErrCtrl_ReceiveInPort_impl<MacReceive> * m_mac_err_ctrl_in;
  MAC_FlowCtrl_InPort_impl<MacReceive> * m_mac_flow_ctrl_in;

  // Uses interface definitions.
  MAC_Ctrl_OutPort_impl<SDR_FM3TR::MAC_Signaling::MAC_Signal_Remote> * m_macout;

  bool m_running;
  bool m_bStop;

  SDR_FM3TR::MAC_Signaling::MAC_Signal_FlowControl m_flow_control_state;
  SDR_FM3TR::MAC_Signaling::MAC_Signal_Ack m_error_control_state;

  // properties
  double                         m_hop_rate;
  SDR_FM3TR::hoppingSubBand      m_freq_hop_sub_band;
  SDR_FM3TR::freqHopSet          m_freq_hop_set;
  bool                           m_flow_control_on;
};

#endif /* MAC_RECEIVE_H__ */
